home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / newmail.c < prev    next >
C/C++ Source or Header  |  1996-07-09  |  20KB  |  621 lines

  1. #if !defined(lint) && !defined(DOS)
  2. static char rcsid[] = "$Id: newmail.c,v 4.68 1996/07/09 22:20:17 mikes Exp $";
  3. #endif
  4. /*----------------------------------------------------------------------
  5.  
  6.             T H E    P I N E    M A I L   S Y S T E M
  7.  
  8.    Laurence Lundblade and Mike Seibel
  9.    Networks and Distributed Computing
  10.    Computing and Communications
  11.    University of Washington
  12.    Administration Builiding, AG-44
  13.    Seattle, Washington, 98195, USA
  14.    Internet: lgl@CAC.Washington.EDU
  15.              mikes@CAC.Washington.EDU
  16.  
  17.    Please address all bugs and comments to "pine-bugs@cac.washington.edu"
  18.  
  19.  
  20.    Pine and Pico are registered trademarks of the University of Washington.
  21.    No commercial use of these trademarks may be made without prior written
  22.    permission of the University of Washington.
  23.  
  24.    Pine, Pico, and Pilot software and its included text are Copyright
  25.    1989-1996 by the University of Washington.
  26.  
  27.    The full text of our legal notices is contained in the file called
  28.    CPYRIGHT, included with this distribution.
  29.  
  30.  
  31.    Pine is in part based on The Elm Mail System:
  32.     ***********************************************************************
  33.     *  The Elm Mail System  -  Revision: 2.13                             *
  34.     *                                                                     *
  35.     *             Copyright (c) 1986, 1987 Dave Taylor              *
  36.     *             Copyright (c) 1988, 1989 USENET Community Trust   *
  37.     ***********************************************************************
  38.  
  39.  
  40.   ----------------------------------------------------------------------*/
  41.  
  42. /*======================================================================
  43.      newmail.c
  44.  
  45.    Check for new mail and queue up notification
  46.  
  47.  ====*/
  48.  
  49. #include "headers.h"
  50.  
  51.  
  52. /*
  53.  * Internal prototypes
  54.  */
  55. void new_mail_mess PROTO((MAILSTREAM *, char *, long, long, int));
  56. void fixup_flags PROTO((MAILSTREAM *, MSGNO_S *, long));
  57.  
  58.  
  59. static long mailbox_mail_since_command = 0L,
  60.         inbox_mail_since_command   = 0L;
  61.  
  62. /*----------------------------------------------------------------------
  63.      new_mail() - check for new mail in the inbox
  64.  
  65.   Input:  force       -- flag indicating we should check for new mail no matter
  66.           time_for_check_point -- 0: GoodTime, 1: BadTime, 2: VeryBadTime
  67.       do_status_message -- flag telling us to q a new mail status message
  68.  
  69.   Result: returns -1 if there was no new mail. Otherwise returns the
  70.           sorted message number of the smallest message number that
  71.           was changed. That is the screen needs to be repainted from
  72.           that message down.
  73.  
  74.   Limit frequency of checks because checks use some resources. That is
  75.   they generate an IMAP packet or require locking the local mailbox.
  76.   (Acutally the lock isn't required, a stat will do, but the current
  77.    c-client mail code locks before it stats.)
  78.  
  79.   Returns >= 0 only if there is a change in the given mail stream. Otherwise
  80.   this returns -1.  On return the message counts in the pine
  81.   structure are updated to reflect the current number of messages including
  82.   any new mail and any expunging.
  83.  
  84.  --- */
  85. long
  86. new_mail(force, time_for_check_point, do_status_msg)
  87.     int force, time_for_check_point, do_status_msg;
  88. {
  89.     static time_t last_check = 0;
  90.     static time_t last_check_point_call = 0;
  91.     time_t        now;
  92.     long          rv;
  93.     MAILSTREAM   *stream;
  94.     register struct pine *pine_state;
  95.     int           checknow = 0;
  96.     int           act_on_deferred = 0;
  97.     int           deferring_sort;
  98.  
  99.     dprint(9, (debugfile, "new mail called (%d %d %d)\n",
  100.                force, time_for_check_point, do_status_msg));
  101.     pine_state = ps_global;  /*  this gets called out of the composer which
  102.                               *  doesn't know about pine_state
  103.                               */
  104.     now = time(0);
  105.  
  106.     deferring_sort = pine_state->sort_is_deferred;    /* for this time */
  107.     pine_state->sort_is_deferred = 0;            /* for next time */
  108.     if(!deferring_sort && pine_state->unsorted_newmail)
  109.       act_on_deferred++;
  110.  
  111.     /*
  112.      * only check every 15 seconds, unless we're compelled to
  113.      */
  114.     if(!(stream = pine_state->mail_stream)
  115.        || (timeout == 0 && !force)
  116.        || (now-last_check_point_call <= 15 && time_for_check_point != 0
  117.        && !pine_state->mail_box_changed && !force
  118.        && !act_on_deferred))
  119.       return(-1);
  120.     else if(force || now-last_check >= timeout-2){ /* 2: check each timeout */
  121.     checknow++;
  122.         last_check = now;
  123.     }
  124.  
  125.     last_check_point_call = now;
  126.  
  127.     if(!check_point(time_for_check_point == 0 ? GoodTime:
  128.           time_for_check_point == 1 ? BadTime : VeryBadTime) && checknow){
  129.     if(F_ON(F_SHOW_DELAY_CUE, ps_global) && !ps_global->in_init_seq){
  130.         StartInverse();
  131.         PutLine0(0, 1, "*");    /* Show something to indicate delay */
  132.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  133.         fflush(stdout);
  134.     }
  135.  
  136. #ifdef    DEBUG
  137.     now = time(0);
  138.     dprint(7, (debugfile, "Mail_Ping(mail_stream): %s\n", ctime(&now)));
  139. #endif
  140.         /*-- Ping the mailstream to check for new mail --*/
  141.         dprint(6, (debugfile, "New mail checked \n"));
  142.     if((char *)mail_ping(stream) == NULL)
  143.       pine_state->dead_stream = 1;
  144.  
  145. #ifdef    DEBUG
  146.     now = time(0);
  147.     dprint(7, (debugfile, "Ping complete: %s\n", ctime(&now)));
  148. #endif
  149.     if(F_ON(F_SHOW_DELAY_CUE, ps_global) && !ps_global->in_init_seq){
  150.         PutLine0(0, 1, " ");
  151.         EndInverse();
  152.         fflush(stdout);
  153.     }
  154.     }
  155.  
  156.     if(checknow && pine_state->inbox_stream 
  157.        && stream != pine_state->inbox_stream){
  158.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  159.         StartInverse();
  160.         PutLine0(0, 1, "*");     /* Show something to indicate delay */
  161.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  162.         fflush(stdout);
  163.     }
  164.  
  165. #ifdef    DEBUG
  166.     now = time(0);
  167.     dprint(7, (debugfile, "Mail_Ping(inbox_stream): %s\n", ctime(&now)));
  168. #endif
  169.     if((char *)mail_ping(pine_state->inbox_stream) == NULL)
  170.       pine_state->dead_inbox = 1;
  171.  
  172. #ifdef    DEBUG
  173.     now = time(0);
  174.     dprint(7, (debugfile, "Ping complete: %s\n", ctime(&now)));
  175. #endif
  176.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  177.         PutLine0(0, 1, " ");
  178.         EndInverse();
  179.         fflush(stdout);
  180.     }
  181.     }
  182.  
  183.  
  184.     /*-------------------------------------------------------------
  185.        Mail box state changed, could be additions or deletions.
  186.       -------------------------------------------------------------*/
  187.     if(pine_state->mail_box_changed || act_on_deferred) {
  188.         dprint(7, (debugfile,
  189.         "New mail, %s,  new_mail_count:%d  expunge count:%d,  max_msgno:%d\n",
  190.                    pine_state->mail_stream == pine_state->inbox_stream ?
  191.                       "inbox" : "other",
  192.                    pine_state->new_mail_count,
  193.                    pine_state->expunge_count,
  194.                    mn_get_total(pine_state->msgmap)));
  195.  
  196.     if(pine_state->mail_box_changed)
  197.       fixup_flags(pine_state->mail_stream, pine_state->msgmap,
  198.             pine_state->new_mail_count);
  199.  
  200.     /*
  201.      * Lastly, worry about sorting if we got something new, otherwise
  202.      * it was taken care of inside mm_expunge...
  203.      */
  204.     if((pine_state->new_mail_count > 0L || pine_state->unsorted_newmail)
  205.        && !deferring_sort
  206.        && !any_lflagged(pine_state->msgmap, MN_HIDE)){
  207.         /*
  208.          * When new mail arrived, mm_exists cleared the cache.
  209.          * However, if we deferred the sort at that time and are
  210.          * sorting now, we need to clear the cache again.
  211.          */
  212.         if(pine_state->unsorted_newmail)
  213.           clear_index_cache();
  214.  
  215.         sort_current_folder(1, mn_get_sort(pine_state->msgmap),
  216.                 mn_get_revsort(pine_state->msgmap));
  217.     }
  218.     else if(pine_state->new_mail_count > 0L)
  219.       pine_state->unsorted_newmail = 1;
  220.  
  221.         if(ps_global->new_mail_count > 0 || mailbox_mail_since_command) {
  222.             mailbox_mail_since_command += ps_global->new_mail_count;
  223.  
  224.             new_mail_mess(pine_state->mail_stream,
  225.                       pine_state->mail_stream == pine_state->inbox_stream ?
  226.                       NULL :  pine_state->cur_folder,
  227.                       mailbox_mail_since_command,
  228.               mn_get_total(pine_state->msgmap),
  229.               do_status_msg);
  230.         }
  231.     }
  232.  
  233.     if(pine_state->inbox_changed
  234.        && pine_state->inbox_stream != pine_state->mail_stream) {
  235.         /*--  New mail for the inbox, queue up the notification           --*/
  236.         /*-- If this happens then inbox is not current stream that's open --*/
  237.         dprint(7, (debugfile,
  238.          "New mail, inbox, new_mail_count:%ld expunge: %ld,  max_msgno %ld\n",
  239.                    pine_state->inbox_new_mail_count,
  240.                    pine_state->inbox_expunge_count,
  241.                    mn_get_total(pine_state->inbox_msgmap)));
  242.  
  243.     fixup_flags(pine_state->inbox_stream, pine_state->inbox_msgmap,
  244.             pine_state->inbox_new_mail_count);
  245.  
  246.         if(pine_state->inbox_new_mail_count > 0 || inbox_mail_since_command) {
  247.             inbox_mail_since_command       += ps_global->inbox_new_mail_count;
  248.             ps_global->inbox_new_mail_count = 0;
  249.             new_mail_mess(pine_state->inbox_stream,NULL,
  250.                           inbox_mail_since_command,
  251.               mn_get_total(pine_state->inbox_msgmap),
  252.               do_status_msg);
  253.         }
  254.     }
  255.  
  256.     rv = mailbox_mail_since_command
  257.      + inbox_mail_since_command + pine_state->expunge_count;
  258.     if(do_status_msg){
  259.     pine_state->inbox_changed    = 0;
  260.     pine_state->mail_box_changed = 0;
  261.     }
  262.  
  263.     ps_global->new_mail_count    = 0L;
  264.  
  265.     if(pine_state->shown_newmail
  266.        && !(mailbox_mail_since_command || inbox_mail_since_command)){
  267.     icon_text(NULL);
  268.     pine_state->shown_newmail = 0;
  269.     }
  270.  
  271.     dprint(6, (debugfile, "******** new mail returning %ld  ********\n", 
  272.            rv ? rv : -1));
  273.     return(rv ? rv : -1);
  274. }
  275.  
  276.  
  277. /*----------------------------------------------------------------------
  278.      Format and queue a "new mail" message
  279.  
  280.   Args: stream     -- mailstream on which a mail has arrived
  281.         folder     -- Name of folder, NULL if inbox
  282.         number     -- number of new messages since last command
  283.         max_num    -- The number of messages now on stream
  284.  
  285.  Not too much worry here about the length of the message because the
  286. status_message code will fit what it can on the screen and truncation on
  287. the right is about what we want which is what will happen.
  288.   ----*/
  289. void
  290. new_mail_mess(stream, folder, number, max_num, do_status_msg)
  291.      MAILSTREAM *stream;
  292.      long        number, max_num;
  293.      char       *folder;
  294.      int         do_status_msg;
  295.  
  296. {
  297.     ENVELOPE    *e;
  298.     char     subject[200], from[2*MAX_SCREEN_COLS], intro[50 + MAXFOLDER];
  299.     static char *carray[] = { "regarding",
  300.                 "concerning",
  301.                 "about",
  302.                 "as to",
  303.                 "as regards",
  304.                 "as respects",
  305.                 "in re",
  306.                 "re",
  307.                 "respecting",
  308.                 "in point of",
  309.                 "with regard to",
  310.                 "subject:"
  311.     };
  312.  
  313. #ifdef _WINDOWS
  314.     mswin_newmailicon ();
  315. #endif
  316.  
  317.     if(!do_status_msg)
  318.       return;
  319.  
  320.     if(!folder) {
  321.         if(number > 1)
  322.           sprintf(intro, "%ld new messages!", number);
  323.         else
  324.           strcpy(intro, "New mail!");
  325.     }
  326.     else {
  327.         if(number > 1)
  328.           sprintf(intro,"%ld messages saved to folder \"%s\"", number, folder);
  329.         else
  330.           sprintf(intro, "Mail saved to folder \"%s\"", folder);
  331.     }
  332.  
  333.     if((e = mail_fetchstructure(stream, max_num, NULL)) && e->from){
  334.     sprintf(from, " %srom ", (number > 1L) ? "Most recent f" : "F");
  335.     if(e->from->personal)
  336.       istrncpy(from + ((number > 1L) ? 18 : 6),
  337.            (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
  338.                        e->from->personal, NULL),
  339.            ps_global->ttyo->screen_cols);
  340.     else
  341.       sprintf(from + ((number > 1L) ? 18 : 6), "%s@%s", 
  342.           e->from->mailbox, e->from->host);
  343.     }
  344.     else
  345.       from[0] = '\0';
  346.  
  347.     if(number <= 1L) {
  348.         if(e && e->subject){
  349.         sprintf(subject, " %s ", carray[(unsigned)random()%12]);
  350.         istrncpy(subject + strlen(subject),
  351.              (char *) rfc1522_decode((unsigned char *) tmp_20k_buf,
  352.                          e->subject, NULL), 100);
  353.     }
  354.     else
  355.       strcpy(subject, " with no subject");
  356.  
  357.         if(!from[0])
  358.           subject[1] = toupper((unsigned char)subject[1]);
  359.  
  360.         q_status_message3(SM_ASYNC | SM_DING, 0, 60,
  361.               "%s%s%s", intro, from, subject);
  362.     }
  363.     else
  364.       q_status_message2(SM_ASYNC | SM_DING, 0, 60, "%s%s", intro, from);
  365.  
  366.     sprintf(tmp_20k_buf, "%s%s", intro, from);
  367.     icon_text(tmp_20k_buf);
  368.     ps_global->shown_newmail = 1;
  369. }
  370.  
  371.  
  372.  
  373. /*----------------------------------------------------------------------
  374.   Straighten out any local flag problems here.  We can't take care of
  375.   them in the mm_exists or mm_expunged callbacks since the flags
  376.   themselves are in an MESSAGECACHE and we're not allowed to reenter
  377.   c-client from a callback...
  378.  
  379.  Args: stream -- mail stream to operate on
  380.        msgmap -- messages in that stream to fix up
  381.        new_msgs -- number of new messages
  382.  
  383.  Result: returns with local flags as they should be
  384.  
  385.   ----*/
  386. void
  387. fixup_flags(stream, msgmap, new_msgs)
  388.     MAILSTREAM *stream;
  389.     MSGNO_S    *msgmap;
  390.     long    new_msgs;
  391. {
  392.     long i;
  393.  
  394.     if(new_msgs > 0L && any_lflagged(msgmap, MN_HIDE)){
  395.     i = mn_get_total(msgmap) - new_msgs + 1L;
  396.     while(i > 0L && i <= mn_get_total(msgmap))
  397.       set_lflag(stream, msgmap, i++, MN_HIDE, 1);
  398.     }
  399.  
  400.     /*
  401.      * Also, worry about the case where expunged away all of the 
  402.      * zoomed messages.  Unhide everything in that case...
  403.      */
  404.     if(mn_get_total(msgmap) > 0L){
  405.     if(any_lflagged(msgmap, MN_HIDE) >= mn_get_total(msgmap)){
  406.         for(i = 1L; i <= mn_get_total(msgmap); i++)
  407.           set_lflag(stream, msgmap, i, MN_HIDE, 0);
  408.  
  409.         mn_set_cur(msgmap, mn_get_total(msgmap));
  410.     }
  411.     else if(any_lflagged(msgmap, MN_HIDE)){
  412.         /*
  413.          * if we got here, there are some hidden messages and
  414.          * some not.  Make sure the current message is one
  415.          * that's not...
  416.          */
  417.         for(i = mn_get_cur(msgmap); i <= mn_get_total(msgmap); i++)
  418.           if(!get_lflag(stream, msgmap, i, MN_HIDE)){
  419.           mn_set_cur(msgmap, i);
  420.           break;
  421.           }
  422.  
  423.         for(i = mn_get_cur(msgmap); i > 0L; i--)
  424.           if(!get_lflag(stream, msgmap, i, MN_HIDE)){
  425.           mn_set_cur(msgmap, i);
  426.           break;
  427.           }
  428.     }
  429.     }
  430. }
  431.  
  432.  
  433.  
  434. /*----------------------------------------------------------------------
  435.     Force write of the main file so user doesn't lose too much when
  436.  something bad happens. The only thing that can get lost is flags, such 
  437.  as when new mail arrives, is read, deleted or answered.
  438.  
  439.  Args: timing      -- indicates if it's a good time for to do a checkpoint
  440.  
  441.   Result: returns 1 if checkpoint was written, 
  442.                   0 if not.
  443.  
  444. NOTE: mail_check will also notice new mail arrival, so it's imperative that
  445. code exist after this function is called that can deal with updating the 
  446. various pieces of pine's state associated with the message count and such.
  447.  
  448. Only need to checkpoint current stream because there are no changes going
  449. on with other streams when we're not manipulating them.
  450.   ----*/
  451. static int check_count        = 0;  /* number of changes since last chk_pt */
  452. static long first_status_change = 0;  /* time of 1st change since last chk_pt*/
  453. static long last_status_change    = 0;  /* time of last change                 */
  454. static long check_count_ave    = 10 * 10;
  455.  
  456. check_point(timing)
  457.      CheckPointTime timing;
  458. {
  459.     int     freq, tm;
  460.     long    adj_cca;
  461.     long    tmp;
  462. #ifdef    DEBUG
  463.     time_t  now;
  464. #endif
  465.  
  466.     dprint(9, (debugfile, "check_point(%s)\n", 
  467.                timing == GoodTime ? "GoodTime" :
  468.                timing == BadTime  ? "BadTime" :
  469.                timing == VeryBadTime  ? "VeryBadTime" : "DoItNow"));
  470.  
  471.     if(!ps_global->mail_stream || ps_global->mail_stream->rdonly ||
  472.                                  check_count == 0)
  473.      return(0);
  474.  
  475.     freq = CHECK_POINT_FREQ * (timing==GoodTime ? 1 : timing==BadTime ? 3 : 4);
  476.     tm   = CHECK_POINT_TIME * (timing==GoodTime ? 1 : timing==BadTime ? 2 : 3);
  477.  
  478.     dprint(9, (debugfile, "freq: %d  count: %d\n", freq, check_count));
  479.     dprint(9, (debugfile, "tm: %d  elapsed: %d\n", tm,
  480.                time(0) - first_status_change));
  481.  
  482.     if(!last_status_change)
  483.         last_status_change = time(0);
  484.  
  485.     tmp = 10*(time(0)-last_status_change);
  486.     adj_cca = (tmp > check_count_ave) ?
  487.       min((check_count_ave + tmp)/2, 2*check_count_ave) : check_count_ave;
  488.  
  489.     dprint(9, (debugfile, "freq %d tm %d changes %d since_1st_change %d\n",
  490.            freq, tm, check_count, time(0)-first_status_change));
  491.     dprint(9, (debugfile, "since_status_chg %d chk_cnt_ave %d (tenths)\n",
  492.            time(0)-last_status_change, check_count_ave));
  493.     dprint(9, (debugfile, "adj_chk_cnt_ave %d (tenths)\n", adj_cca));
  494.     dprint(9, (debugfile, "Check:if changes(%d)xadj_cca(%d) >= freq(%d)x200\n",
  495.            check_count, adj_cca, freq));
  496.     dprint(9, (debugfile, "      is %d >= %d ?\n",
  497.            check_count*adj_cca, 200*freq));
  498.  
  499.     /* the 200 comes from 20 seconds for an average status change time
  500.        multiplied by 10 tenths per second */
  501.     if((timing == DoItNow || (check_count * adj_cca >= freq * 200) ||
  502.        (time(0) - first_status_change >= tm))){
  503. #ifdef    DEBUG
  504.     now = time(0);
  505.     dprint(7, (debugfile,
  506.                      "Doing checkpoint: %s  Since 1st status change: %d\n",
  507.                      ctime(&now), now - first_status_change));
  508. #endif
  509.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  510.         StartInverse();
  511.         PutLine0(0, 0, "**");    /* Show something indicate delay*/
  512.         MoveCursor(ps_global->ttyo->screen_rows -FOOTER_ROWS(ps_global),0);
  513.         fflush(stdout);
  514.     }
  515.  
  516.         mail_check(ps_global->mail_stream);
  517.                     /* Causes mail file to be written */
  518. #ifdef    DEBUG
  519.     now = time(0);
  520.     dprint(7, (debugfile, "Checkpoint complete: %s\n", ctime(&now)));
  521. #endif
  522.         check_count = 0;
  523.         first_status_change = time(0);
  524.     if(F_ON(F_SHOW_DELAY_CUE, ps_global)){
  525.         PutLine0(0, 0, "  ");
  526.         EndInverse();
  527.         fflush(stdout);
  528.     }
  529.  
  530.         return(1);
  531.     } else {
  532.         return(0);
  533.     }
  534. }
  535.  
  536.  
  537.  
  538. /*----------------------------------------------------------------------
  539.     Call this when we need to tell the check pointing mechanism about
  540.   mailbox state changes.
  541.   ----------------------------------------------------------------------*/
  542. void
  543. check_point_change()
  544. {
  545.     if(!last_status_change)
  546.         last_status_change = time(0) - 10;  /* first change 10 seconds */
  547.  
  548.     if(!check_count++)
  549.       first_status_change = time(0);
  550.     /*
  551.      * check_count_ave is the exponentially decaying average time between
  552.      * status changes, in tenths of seconds, except never grow by more
  553.      * than double, but always at least one (unless there's a fulll moon).
  554.      */
  555.     check_count_ave = min((check_count_ave +
  556.                 max(10*(time(0)-last_status_change),2))/2, 2*check_count_ave);
  557.  
  558.     last_status_change = time(0);
  559. }
  560.  
  561.  
  562.  
  563. /*----------------------------------------------------------------------
  564.     Call this when a mail file is written to reset timer and counter
  565.   for next check_point.
  566.   ----------------------------------------------------------------------*/
  567. void
  568. reset_check_point()
  569. {
  570.     check_count = 0;
  571.     first_status_change = time(0);
  572. }
  573.  
  574.  
  575.  
  576. /*----------------------------------------------------------------------
  577.     Zero the counters that keep track of mail accumulated between
  578.    commands.
  579.  ----*/
  580. void
  581. zero_new_mail_count()
  582. {
  583.     dprint(9, (debugfile, "New_mail_count zeroed\n"));
  584.     mailbox_mail_since_command = 0L;
  585.     inbox_mail_since_command   = 0L;
  586. }
  587.  
  588.  
  589. /*----------------------------------------------------------------------
  590.      Check and see if all the stream are alive
  591.  
  592. Returns:  0 if there was no change
  593.           1 if streams have died since last call
  594.  
  595. Also outputs a message that the streams have died
  596.  ----*/
  597. streams_died()
  598. {
  599.     int rv = 0, inbox = 0;
  600.  
  601.     if(ps_global->dead_stream && !ps_global->noticed_dead_stream) {
  602.         rv = 1;
  603.         ps_global->noticed_dead_stream = 1;
  604.         if(ps_global->mail_stream == ps_global->inbox_stream)
  605.           ps_global->noticed_dead_inbox = 1;
  606.     }
  607.  
  608.     if(ps_global->dead_inbox && !ps_global->noticed_dead_inbox) {
  609.         rv = 1;
  610.         ps_global->noticed_dead_inbox = 1;
  611.         inbox = 1;
  612.     }
  613.     if(rv == 1) 
  614.       q_status_message1(SM_ORDER | SM_DING, 3, 6,
  615.                         "MAIL FOLDER \"%s\" CLOSED DUE TO ACCESS ERROR",
  616.                         pretty_fn(inbox ? ps_global->inbox_name
  617.                       : ps_global->cur_folder));
  618.     return(rv);
  619. }
  620.         
  621.